﻿using System;
using System.Collections.ObjectModel;
using TheMovieDb;

namespace MovieDB4.Managers
{
    class DownloadManager
    { 
        static readonly TmdbApi Api = new TmdbApi("0b513d6b1b6e57761f496a2c4b595c90");

        private ObservableCollection<TmdbMovie> MovieResults { get; set; }

        public DownloadManager()
        {
            MovieResults = new ObservableCollection<TmdbMovie>();
            Api.MovieSearchCompleted += SearchComplete;
        }

        public void FindMovie(string searchString)
        {
            Api.MovieSearchAsync(searchString);
        }

        public void SearchComplete(object sender, TmdbMovieSearchCompletedEventArgs e)
        {
            var result = e.Movies;
            foreach (var tmdbMovie in result)
            {
                MovieResults.Add(tmdbMovie);
                Console.WriteLine(tmdbMovie.Name);
            }

            //Send to trimmer which finds most correct result
        }
    }
}